<template>
  <div class="app-container">

    <el-form :inline="true" class="demo-form-inline">

      <el-form-item>
        <el-input v-model="searchObj.orderId" placeholder="订单号"/>
      </el-form-item>

      <el-form-item>
        <el-input v-model="searchObj.userId" placeholder="用户id"/>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="fetchData()">查询</el-button>
        <el-button type="default" @click="resetData()">清空</el-button>
      </el-form-item>
    </el-form>

    <!-- banner列表 -->
    <el-table v-loading="listLoading" :data="list"
              border
              fit
              highlight-current-row>

      <el-table-column prop="orderId" label="订单号"/>
      <el-table-column prop="userId" label="用户id"/>
      <el-table-column prop="userName" label="用户名"/>
      <el-table-column prop="receipt" label="收货地址"/>
      <el-table-column prop="total" label="总价"/>
      <el-table-column prop="createTime" label="创建时间"/>
      <!--      <el-table-column label="状态" width="80">-->
      <!--        <template slot-scope="scope">-->
      <!--          <el-tag effect="plain" v-text="未处理"></el-tag>-->
      <!--        </template>-->
      <!--      </el-table-column>-->

    </el-table>

    <!-- 分页组件 -->
    <el-pagination
      :current-page="page"
      :total="total"
      :page-size="limit"
      :page-sizes="[5, 10, 20, 30, 40, 50, 100]"
      style="padding: 30px 0; text-align: center;"
      layout="sizes, prev, pager, next, jumper, ->, total, slot"
      @current-change="fetchData"
      @size-change="changeSize"
    />

  </div>
</template>

<script>
export default {
  name: "invalid-order",
  data(){
    return{
      list: null, // 订单列表
      total: 0, // 数据库中的总记录数
      page: 1, // 默认页码
      limit: 5, // 每页记录数
      listLoading: true, // 数据是否正在加载
      searchObj: {
        orderId: null,
        userId: null,
        status: 5   //查询失效订单
      },
      size: '',
      order: {
        orderId: null,
        userName: null,
        receipt: null,
        status: null,
        createTime: null,
        goodsList: null,
        total: null
      },
    }
  },
  methods:{
    fetchData(page = 1){
      this.page = page
      this.$http({
        url: this.$http.adornUrl(`/order/goods/list/${page}/${this.limit}`),
        method: 'get',
        params: this.searchObj
      }).then(({data}) => {
        console.log(data)
        this.list = data.data.records
        this.total = data.data.total
        this.listLoading = false
      })
    },
    // 重置查询表单
    resetData() {
      this.searchObj = {}
      this.searchObj.status=5
      this.fetchData()
    },
    // 页码切换
    changeSize(val) {
      this.limit = val
      this.page = 1
      this.fetchData(1)
    },
  },
  created() {
    this.fetchData()
  },
}
</script>

<style scoped>

</style>
